﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ManageStore.Common
{
    public class Utilities
    {
    }

    public static class TreeViewCus
    {
        public static TreeNode FindNode(this TreeView pTreeView, string pName)
        {
            return FindAll(pTreeView.Nodes, pName);
        }
        private static TreeNode FindAll(TreeNodeCollection pNodes, string pName)
        {
            if (pNodes != null)
                foreach (TreeNode item in pNodes)
                {
                    if (item.Name == pName)
                        return item;
                    else
                    {
                        TreeNode node = FindAll(item.Nodes, pName);
                        if (node != null)
                            return node;
                    }
                }
            return null;
        }
    }
}
